class Solution {
public:
    void rotate(vector<int>& nums, int k)
    {
        int n = nums.size();
        vector<int> newArr(n);

        for (int i = 0; i < n; ++i)
        {
            newArr[(i + k) % n] = nums[i];
        }

        nums.assign(newArr.begin(), newArr.end());
    }
};
